package cn.mengfly.testnrz.im.client.bean;

import cn.mengfly.testnrz.im.ProtoMsg;
import lombok.Data;

import java.io.Serializable;

@Data
public class User implements Serializable {

    String uid;
    String deviceId;
    String token;
    String nickName = "nickName";
    PlatType platType = PlatType.WINDOWS;
    String sessionId;

    public void setPlatForm(int platForm) {
        PlatType[] values = PlatType.values();
        for (PlatType value : values) {
            if (value.ordinal() == platForm) {
                this.platType = value;
            }
        }
    }

    public static User fromMsg(ProtoMsg.LoginRequest info) {
        User user = new User();
        user.uid = info.getUid();
        user.deviceId = info.getDeviceId();
        user.token = info.getToken();
        user.setPlatForm(info.getPlatform());
        System.out.println("登录中" + user.toString());
        return user;
    }

    public Object getUserId() {
        // TODO userId =
        return null;
    }
}
